Skip to content

feat(agents): HIP-3 MM strategies + new Delta-Neutral Funding Agent - #165

Merged
fengtality merged 5 commits into
mainfrom
feat/mm-expert-hip3-examples
Jul 30, 2026
Merged

feat(agents): HIP-3 MM strategies + new Delta-Neutral Funding Agent#165
fengtality merged 5 commits into
mainfrom
feat/mm-expert-hip3-examples

Conversation

@fengtality

@fengtality fengtality commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Adds HIP-3 (xyz-issuer perps on hyperliquid_perpetual) trading content: a new Delta-Neutral Funding Agent and an mm-operator strategy for the existing market_making_expert. Strategy files only — the framework-side executor + P&L attribution for these bot-mode agents is a separate PR (#166).

New agent: delta_neutral_funding_agent

Delta-neutral funding is a distinct domain (funding-carry pair trading, not spread/inventory MM), so it lives in its own agent rather than under market_making_expert:

  • AGENT.md — identity, consult triggers, and the always-on HIP-3 domain rules (UPPERCASE XYZ: prefix, unified collateral, per-order min-notional, fee reality).
  • hip_3_delta_neutral_funding_mm strategy — delta-neutral MM + funding harvest on a correlated pair (default CL/BRENTOIL, corr 0.98, β 1.02). Two pmm_mister controllers in one bot, beta-weighted long/short so net market delta ≈ 0, leaned to the funding-favorable side so both legs pay. Neutrality is INDUCED by re-tuning the controllers — never market-hedged. Funding hysteresis gates A/B flips; per-order min-notional floor enforced in sizing.
  • hip3_dn_pair_monitor routine — per-tick analysis brain: live beta + drift, correlation gate, per-leg funding + net carry, and the actual net factor delta (IN-BAND / BREACH) from live positions.
  • hip3_pairs_backtest routine — correlation / pair validation at launch.

market_making_expert additions

  • hip_3_mm_operator strategy — HIP-3 volume-farming MM operator.
  • hip3_market_scanner routine — HIP-3 pair discovery/ranking used by the operator.

Skill

  • hyperliquid_tokenized_perps — warns the HIP-3 issuer prefix is case-sensitive (lowercase → connector KeyError → 0 orders).

Scope

🤖 Generated with Claude Code

@fengtality
fengtality force-pushed the feat/mm-expert-hip3-examples branch from 03d3210 to 1ff6caf Compare July 24, 2026 21:05
@fengtality fengtality changed the title feat(mm-expert): HIP-3 market-making agent examples + bot P&L attribution fix feat(mm-expert): HIP-3 market-making agent strategies Jul 24, 2026
@rapcmia rapcmia moved this to Backlog in Pull Request Board Jul 28, 2026
@rapcmia rapcmia moved this from Backlog to Under Review in Pull Request Board Jul 28, 2026
@rapcmia

rapcmia commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Commit 20936d8

  • Setup with hummingbot-api (docker)
  • Most of the test use XYZ HIP-3 perp markets
  • Confirm both HIP-3 strategies appear in the agent UI and their routines are available. ✅
    image

Scans HIP-3 markets, checks volume/spread/drift/depth, outputs top pick.

#### XYZ:
HIP-3 Market Scanner — issuer: XYZ
Scanned: 103 markets | Pre-filter pass: 38 | Depth-checked: 12 | Survivors: 9 | Top-30 shown
Filters: spread >= 3.0bps | drift <= 3.0% | OI >= $1,000,000 | depth >= $10,000/side within 10.0bps
Fee context: 2.6bps round-trip (~1.30bps/side)

TOP PICK: XYZ:MRVL-USD

XYZ:MRVL-USD: Vol=$41,376,912 | Spread=7.73bps | Drift=1.47% | Depth=$90,258/side | OI=$26,897,898 | Lev=10x | Score=19.269
XYZ:AMD-USD: Vol=$36,792,798 | Spread=6.19bps | Drift=0.60% | Depth=$65,590/side | OI=$7,066,366 | Lev=10x | Score=19.038
XYZ:GOOGL-USD: Vol=$51,813,786 | Spread=3.04bps | Drift=0.36% | Depth=$84,001/side | OI=$95,915,389 | Lev=20x | Score=18.531
XYZ:NFLX-USD: Vol=$14,585,055 | Spread=6.36bps | Drift=0.13% | Depth=$16,514/side | OI=$8,989,243 | Lev=10x | Score=18.351
XYZ:INTC-USD: Vol=$73,719,753 | Spread=3.75bps | Drift=2.87% | Depth=$66,822/side | OI=$35,447,163 | Lev=10x | Score=18.093
XYZ:TSLA-USD: Vol=$41,563,012 | Spread=3.09bps | Drift=1.35% | Depth=$119,043/side | OI=$38,073,543 | Lev=20x | Score=17.929
XYZ:CRWV-USD: Vol=$13,117,138 | Spread=8.17bps | Drift=2.77% | Depth=$12,548/side | OI=$4,778,750 | Lev=10x | Score=17.680
XYZ:HOOD-USD: Vol=$23,220,085 | Spread=5.06bps | Drift=2.46% | Depth=$43,216/side | OI=$16,371,591 | Lev=10x | Score=17.495
XYZ:ORCL-USD: Vol=$11,841,718 | Spread=3.56bps | Drift=0.47% | Depth=$89,244/side | OI=$32,614,633 | Lev=10x | Score=17.168

...

#### HYNA:
HIP-3 Market Scanner — issuer: HYNA
Scanned: 25 markets | Pre-filter pass: 0 | Depth-checked: 0 | Survivors: 0 | Top-30 shown
Filters: spread >= 3.0bps | drift <= 3.0% | OI >= $1,000,000 | depth >= $10,000/side within 10.0bps
Fee context: 2.6bps round-trip (~1.30bps/side)

WARNING: NONE PASSED FILTERS — top 5 by volume (informational):
1. HYNA:ETH-USD: Vol=$1,329,804 | Spread=1.35bps | Drift=0.93% | Depth=n/a/side | OI=$1,424,362 | Lev=25x [NO FILTER PASS]
2. HYNA:BTC-USD: Vol=$1,089,979 | Spread=1.28bps | Drift=0.89% | Depth=n/a/side | OI=$2,095,881 | Lev=40x [NO FILTER PASS]
3. HYNA:SOL-USD: Vol=$179,339 | Spread=4.07bps | Drift=0.99% | Depth=n/a/side | OI=$502,665 | Lev=20x [NO FILTER PASS]
4. HYNA:HYPE-USD: Vol=$143,023 | Spread=3.49bps | Drift=2.68% | Depth=n/a/side | OI=$802,599 | Lev=10x [NO FILTER PASS]
5. HYNA:ENA-USD: Vol=$87,195 | Spread=27.64bps | Drift=0.55% | Depth=n/a/side | OI=$470,881 | Lev=10x [NO FILTER PASS]
  • Verified that the routine successfully scanned the available HIP-3 markets.
  • Verified that the configured filters were applied during the scan.
  • Verified that the dashboard displayed the scan summary (Markets Scanned, Survivors, Top Pick, and Fee Round Trip).
  • Verified that the market scan results were displayed in a ranked table.

Pair Backtest (hip3_pairs_backtest) - Validate pair stat-arb profitability and market neutrality on historical data.

HIP-3 Pair Backtest — INTC / BRENTOIL
Config: interval=1h, lookback=45d, hedge_window=168, entry_z=1.5, exit_z=0.3, momentum_lb=48, fee=1.3bps/side
Data: 1081 aligned bars | 45.0 days

━━ 1. PAIR STATS ━━
Return correlation: -0.1131 (gate ≥0.5) → FAIL ✗
Ann vol INTC: 101.93%
Ann vol BRENTOIL: 49.30%
Avg rolling beta: -0.0429

━━ 2. STATIC BASELINES ━━
Always-long spread: -381.50%/yr
Always-short spread: 380.27%/yr

━━ 3. SIGNAL RESULTS ━━
REVERSION:
Trades: 6
Net total: -0.5012
Ann net: -590.16%/yr
Sharpe: -6.498
Max DD: 59.38%
Sim bars: 744
⚠ SAMPLE TOO SMALL (6 trades < 30) — Sharpe -6.50 is NOT statistically meaningful
⚠ ALWAYS-LONG baseline (-381.5%/yr) captures ≥50% of reversion return — return is largely in-sample directional drift, NOT repeatable reversion alpha
⚠ ALWAYS-SHORT baseline (380.3%/yr) captures ≥50% of reversion return — return is largely in-sample directional drift, NOT repeatable reversion alpha

MOMENTUM:
Trades: 11
Net total: 0.3425
Ann net: 403.27%/yr
Sharpe: 3.512
Max DD: 18.19%
Sim bars: 744
⚠ SAMPLE TOO SMALL (11 trades < 30) — Sharpe 3.51 is NOT statistically meaningful
⚠ ALWAYS-LONG baseline (-381.5%/yr) captures ≥50% of momentum return — return is largely in-sample directional drift, NOT repeatable momentum alpha
⚠ ALWAYS-SHORT baseline (380.3%/yr) captures ≥50% of momentum return — return is largely in-sample directional drift, NOT repeatable momentum alpha

━━ VERDICT ━━
Corr gate (≥0.5): FAIL ✗ (-0.113)
Rev trades ≥ 30: FAIL ✗ (6 trades)
Mom trades ≥ 30: FAIL ✗ (11 trades)
Rev ann net > 0: FAIL ✗ (-590.2%/yr)
Mom ann net > 0: PASS ✓ (403.3%/yr)

NO-GO: return-correlation -0.113 < 0.5 (min_corr) — legs are not sufficiently correlated; spread has too much idiosyncratic noise.
  • Ran the pair backtest using historical market data.
  • Verified that the routine generated the backtest results, no found error on the condor logs
  • The routine analyzed the pair and evaluated the available signals.
  • The routine returned a NO-GO result when the pair did not meet the required criteria.

Live Pair & Delta Monitor (hip3_dn_pair_monitor) - Check live funding rates, OLS hedge beta, and actual position delta balance.

HIP-3 DN Pair Monitor — EWT / EWJ
Window: 168h 1h candles | 168 return bars

RECOMMENDATION: HOLD/FLATTEN: correlation broke (corr=0.721 < min=0.9) — hedge unreliable; reduce or flatten positions.
WARNING: LONG leg (EWJ) funding > 0 (5.5%/yr) — long is also paying, carry compressed

── MARKET DATA ──
Mark EWT : $91.2950
Mark EWJ : $90.4930

── BETA & CORRELATION ──
Live hedge beta : 1.2475 (configured: 1.0200, drift: 22.3%)
Return correlation: 0.7211 (gate >=0.9) -> FAIL
Ann vol EWT : 63.7%
Ann vol EWJ : 36.8%

── FUNDING (live, per-hour -> annualized) ──
EWT funding: 24.104 micro/hr (+21.1%/yr)
EWJ funding: 6.250 micro/hr (+5.5%/yr)

── CONFIG COMPARISON ──
Config A (LONG EWT / SHORT EWJ): -14.3%/yr
Config B (SHORT EWT / LONG EWJ): +14.3%/yr
Recommended : Config B (SHORT EWT / LONG EWJ)
Net carry (best) : +14.3%/yr

── TARGET SIZING (theoretical, live B) ──
Gross notional: $500.00
Leg A (EWT): $222.47 (SHORT)
Leg B (EWJ): $277.53 (LONG)
Net factor delta TARGET (theoretical): 0.0000 (band +/-50.00)

── ACTUAL POSITIONS ──
no live position — flat (actual delta = 0.00)
  • The routine calculated hedge ratio, correlation, and target position sizing.
  • Returned a HOLD/FLATTEN recommendation when the pair did not meet the required criteria.
  • Verified that no active positions were detected and the current position status was flat (opened HYPE-USD) from exchange manually but found that it updated the response from no-position to in-band
    image
  • No error upon generating the report file (.html)

  • For both hip3_dn_pair_monitor and hip3_pairs_backtest
    • I tried to play with the config until i got the verdict as GO but no avail yet
    • The configuration for each routine feels a bit technical due to the number of available settings. It might be helpful to provide a recommended default values or highlight the settings that most users are likely to adjust?❓
  • Also the PR still have changes from feat(lp-agent): add Solana DEX LP Expert — autonomous CLMM liquidity provisioning #162

fengtality and others added 5 commits July 30, 2026 15:56
Three HIP-3 (xyz-issuer perps on hyperliquid_perpetual) examples for the
market_making_expert agent:

- hip_3_delta_neutral_funding_mm: delta-neutral MM + funding harvest on a
  correlated pair (default CL/BRENTOIL). Two pmm_mister controllers in one
  bot, beta-weighted long/short so net market delta ~0, leaned to the
  funding-favorable side. The hip3_dn_pair_monitor routine is the analysis
  brain: it fetches live positions and reports the ACTUAL net factor delta
  (in-band / breach) each tick, plus a tightened ±$20 band.
- hip_3_mm_operator: HIP-3 volume-farming MM operator.
- routines: hip3_dn_pair_monitor, hip3_market_scanner, hip3_pairs_backtest.

Strategy config carries a stable bot_name for the shared bot. Correct
executor + P&L attribution for these bot-mode agents across the dashboard
and the agent's core-data view is handled by the framework (PR #166), kept
separate from these strategy files.

.gitignore: agent runtime artifacts (learnings.md, sessions/).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9Vygff6wPFpmZb5gahuW4
…d funding hysteresis

Rewrite the HIP-3 delta-neutral MM strategy so neutrality is INDUCED through
the market-making itself — throttle the over-accumulated leg / accelerate the
laggard via each pmm_mister controller's spreads, *_amounts_pct, take_profit
and target/min/max_base_pct — and NEVER via market/hedge orders. The routine's
HEDGE recommendation is now read as REBALANCE (re-tune, don't hedge).

Add funding hysteresis: gate every A/B orientation flip on the other config's
carry beating the current by >= flip_margin_pct_yr (default 15%/yr), damping
the dual-paying-compression flip oscillation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9Vygff6wPFpmZb5gahuW4
The trading connector builds its symbol map by uppercasing the exchange
symbol, so a lowercase pair (xyz:SPCX-USD) KeyErrors at trade time and a
deployed bot silently stops without placing an order. The price/candle
endpoints normalize case and give a false 'case-insensitive' signal.

Belongs with the HIP-3 market-making strategy, not the LP agent PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9Vygff6wPFpmZb5gahuW4
Every HIP-3 market enforces a per-order minimum notional (XYZ:CL-USD = $10).
The multi-level default split each leg into sub-minimum orders, so on a small
account orders intermittently failed with "lower than minimum notional size"
after base-lot quantization rounded them down.

Size for one spread level per side with portfolio_allocation 0.5 so each order
clears the floor with margin, and hold the leg with an alert when even a single
order can't reach the market minimum rather than spamming failed orders.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The HIP-3 delta-neutral funding MM is a distinct domain (funding-carry pair
trading, not spread/inventory market making), so it moves out of
market_making_expert into a new Delta-Neutral Funding Agent
(agents/delta_neutral_funding_agent) with its own AGENT.md identity.

Moved with it: the hip_3_delta_neutral_funding_mm strategy playbook and its
two routines (hip3_dn_pair_monitor, hip3_pairs_backtest). hip3_market_scanner
stays with market_making_expert — it belongs to the hip_3_mm_operator
strategy. The strategy_id in the playbook's routine call is updated to the
new agent slug; routine discovery and resolution are directory-based, so the
bare routine names keep working under the new agent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@fengtality
fengtality force-pushed the feat/mm-expert-hip3-examples branch from 20936d8 to a335c86 Compare July 30, 2026 23:00
@fengtality fengtality changed the title feat(mm-expert): HIP-3 market-making agent strategies feat(agents): HIP-3 MM strategies + new Delta-Neutral Funding Agent Jul 30, 2026
@fengtality
fengtality merged commit 89b2556 into main Jul 30, 2026
@rapcmia rapcmia moved this from Under Review to Condor in Pull Request Board Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Condor

Development

Successfully merging this pull request may close these issues.

2 participants